home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / PIELOGO.ARJ / PSGRAF.C < prev    next >
C/C++ Source or Header  |  1992-02-02  |  1KB  |  56 lines

  1. /* Psgraf.c     Copyright (c) 1992 Kevin Stokes, Pie in the Sky Software */
  2.  
  3. #include <stdio.h>
  4. #include <math.h>
  5. #include <malloc.h>
  6.  
  7. extern FILE *psfileptr;
  8.  
  9. void psinit(psnameptr)
  10. char *psnameptr;
  11. {
  12. FILE *pshdrfile;
  13. int c;
  14. if(psnameptr != NULL) psfileptr = fopen(psnameptr,"w");
  15. while (psfileptr == NULL) {
  16.   printf("\nEnter postscript output file name : ");
  17.   scanf("%s",psnameptr);
  18.   psfileptr = fopen(psnameptr,"w"); 
  19.   if(psfileptr == NULL) printf("\n Error opening file : %s\n",psnameptr);
  20.   }
  21. pshdrfile = fopen("psheader","r");
  22.   if(pshdrfile == NULL) {printf("psheader file missing"); exit(0);}
  23.   while((c = getc(pshdrfile)) != EOF)
  24.      putc(c,psfileptr);
  25.   fclose(pshdrfile);
  26. /* fprintf(psfileptr,"\nThis is a damn Postscript file\n"); */
  27. }
  28.  
  29. void psclose()
  30. {
  31. FILE *pshdrfile;
  32. int c;
  33. /* fprintf(psfileptr,"\nThis is the end of the damn Postscript file\n"); */
  34. pshdrfile = fopen("pstrailr","r");
  35.   if(pshdrfile == NULL) {printf("psheader file missing"); exit(0);}
  36.   while((c = getc(pshdrfile)) != EOF)
  37.      putc(c,psfileptr);
  38.   fclose(pshdrfile);
  39. psfileptr = fclose(psfileptr);
  40. }
  41.  
  42. int psscale(argu)
  43. int argu;
  44. {
  45. return((int) ( (float) argu*5000./640.));
  46. }
  47.  
  48. void psline(argx1,argy1,argx2,argy2)
  49. int argx1,argy1,argx2,argy2;
  50. {
  51.     fprintf(psfileptr,"%d %d M\n",psscale(640-argx1),psscale(argy1));
  52.     fprintf(psfileptr,"%d %d C\n",psscale(640-argx2),psscale(argy2));
  53.     fprintf(psfileptr,"stroke\n");
  54. }
  55.  
  56.